/**
 * Definition for singly-linked list.
 * function ListNode(val) {
 *     this.val = val;
 *     this.next = null;
 * }
 */

function hasCircle(head) {
    while(head) {
        if(head.flag) {
            return true
        } else {
            head.flag = true
            head = head.next
        }
    }
    return false
}